import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { AddressType } from '@/apis/components/addressType'

export const useAddressStore = defineStore(
  'address',
  () => {
    const address = ref<AddressType>({
      id: '',
      receiver: '',
      contact: '',
      provinceCode: '',
      cityCode: '',
      countyCode: '',
      address: '',
      postalCode: '',
      addressTags: '',
      isDefault: 1,
      fullLocation: '',
    })

    const clearAddress = () => {
      address.value = {
        id: '',
        receiver: '',
        contact: '',
        provinceCode: '',
        cityCode: '',
        countyCode: '',
        address: '',
        postalCode: '',
        addressTags: '',
        isDefault: 1,
        fullLocation: '',
      }
    }

    return { address, clearAddress }
  },
  // {
  //   persist: true,
  // },
)
